package com.nbsaas.boot.data.rest.convert;

import com.nbsaas.boot.data.data.entity.QueryPrivateTemplate;
import com.nbsaas.boot.data.api.domain.simple.QueryPrivateTemplateSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* -列表对象转换器
*/

public class QueryPrivateTemplateSimpleConvert implements Converter<QueryPrivateTemplateSimple, QueryPrivateTemplate> {




@Override
public QueryPrivateTemplateSimple convert(QueryPrivateTemplate source) {
    QueryPrivateTemplateSimple result = new QueryPrivateTemplateSimple();

                if(source.getDataScope6()!=null){
                   Map<Integer,String> DataScope6Map=new HashMap<>();
                       DataScope6Map.put(1,"部分数据");
                       DataScope6Map.put(2,"全部数据");
                   String label=  DataScope6Map.get(source.getDataScope6());
                   result.setDataScope6Name(label);
                }
                result.setDataScope6(source.getDataScope6());
                result.setNote(source.getNote());
                if(source.getDataScope2()!=null){
                   Map<Integer,String> DataScope2Map=new HashMap<>();
                       DataScope2Map.put(1,"部分数据");
                       DataScope2Map.put(2,"全部数据");
                   String label=  DataScope2Map.get(source.getDataScope2());
                   result.setDataScope2Name(label);
                }
                result.setDataScope2(source.getDataScope2());

                try {
                    if(source.getQueryCatalog()!=null){
                        result.setQueryCatalogName(source.getQueryCatalog().getName());
                    }
                } catch (Exception ignored) { }

                result.setDateRange(source.getDateRange());
                if(source.getDataScope3()!=null){
                   Map<Integer,String> DataScope3Map=new HashMap<>();
                       DataScope3Map.put(1,"部分数据");
                       DataScope3Map.put(2,"全部数据");
                   String label=  DataScope3Map.get(source.getDataScope3());
                   result.setDataScope3Name(label);
                }
                result.setDataScope3(source.getDataScope3());
                if(source.getDataScope4()!=null){
                   Map<Integer,String> DataScope4Map=new HashMap<>();
                       DataScope4Map.put(1,"部分数据");
                       DataScope4Map.put(2,"全部数据");
                   String label=  DataScope4Map.get(source.getDataScope4());
                   result.setDataScope4Name(label);
                }
                result.setDataScope4(source.getDataScope4());

               try {
                   if(source.getModifier()!=null){
                       result.setModifier(source.getModifier().getId());
                   }
                } catch (Exception ignored) { }

                if(source.getDataScope5()!=null){
                   Map<Integer,String> DataScope5Map=new HashMap<>();
                       DataScope5Map.put(1,"部分数据");
                       DataScope5Map.put(2,"全部数据");
                   String label=  DataScope5Map.get(source.getDataScope5());
                   result.setDataScope5Name(label);
                }
                result.setDataScope5(source.getDataScope5());

                try {
                    if(source.getCreator()!=null){
                        result.setCreatorName(source.getCreator().getName());
                    }
                } catch (Exception ignored) { }

                result.setClassName(source.getClassName());
                result.setSlowQuery(source.getSlowQuery());
                if(source.getDataScope1()!=null){
                   Map<Integer,String> DataScope1Map=new HashMap<>();
                       DataScope1Map.put(1,"部分数据");
                       DataScope1Map.put(2,"全部数据");
                   String label=  DataScope1Map.get(source.getDataScope1());
                   result.setDataScope1Name(label);
                }
                result.setDataScope1(source.getDataScope1());
                if(source.getType()!=null){
                   Map<Integer,String> TypeMap=new HashMap<>();
                       TypeMap.put(1,"公共查询");
                       TypeMap.put(2,"私有查询");
                   String label=  TypeMap.get(source.getType());
                   result.setTypeName(label);
                }
                result.setType(source.getType());
                result.setHeaderStyle(source.getHeaderStyle());

               try {
                   if(source.getQueryCatalog()!=null){
                       result.setQueryCatalog(source.getQueryCatalog().getId());
                   }
                } catch (Exception ignored) { }

                result.setModel(source.getModel());
                result.setResultHandleType(source.getResultHandleType());
                result.setId(source.getId());
                result.setTenant(source.getTenant());
                result.setLastDate(source.getLastDate());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                result.setPermission(source.getPermission());
                result.setAddDate(source.getAddDate());
                if(source.getQueryType()!=null){
                   Map<Integer,String> QueryTypeMap=new HashMap<>();
                       QueryTypeMap.put(1,"查询");
                       QueryTypeMap.put(2,"报表");
                       QueryTypeMap.put(101,"批量查询");
                       QueryTypeMap.put(4,"待办");
                   String label=  QueryTypeMap.get(source.getQueryType());
                   result.setQueryTypeName(label);
                }
                result.setQueryType(source.getQueryType());
                result.setStoreProcedure(source.getStoreProcedure());
                result.setName(source.getName());

                try {
                    if(source.getModifier()!=null){
                        result.setModifierName(source.getModifier().getName());
                    }
                } catch (Exception ignored) { }

                result.setCacheModel(source.getCacheModel());
                if(source.getDebugMode()!=null){
                   Map<Integer,String> DebugModeMap=new HashMap<>();
                       DebugModeMap.put(1,"调试模式");
                       DebugModeMap.put(2,"运行模式");
                   String label=  DebugModeMap.get(source.getDebugMode());
                   result.setDebugModeName(label);
                }
                result.setDebugMode(source.getDebugMode());


    return result;
}

}